package core.command
{
	import core.event.SocketEventID;
	import core.event.UnoEvent;
	import core.event.ViewEventID;

	public class PassCommand extends SuperCommand
	{
		public function PassCommand()
		{
			socketEvent = SocketEventID.PASS;
			viewEvent = ViewEventID.PASS;
		}
		
		override public function success(e:UnoEvent):void
		{
			var seat:Object = db.tableList[db.loginUser.table]["config"][e.data.seat];
			
			for(var i:int = 0; i<e.data.card.length; i++)
			{
				addCard(seat, e.data.card[i]);
			}
		}
		
		private function addCard(seat:Object, card:String):void
		{
			for(var i:int = 0; i<100; i++)
			{
				if(seat["cards"].hasOwnProperty(i.toString()))
				{
					continue;
				}
				else
				{
					seat["cards"][i] = card;
					break;
				}
			}
		}
	}
}